package com.fernandomdo.ServiceAdministrator;

// Android Imports
import java.io.IOException;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;

import com.fernandomdo.ServiceAdministrator.databaseInterface.DatabaseInterface;
import com.fernandomdo.ServiceAdministrator.databaseInterface.DatabaseInterface.DatabaseConstants;

// Project Imports

public class ExportDatabase extends Activity {
	private Context appContext;
	private DatabaseInterface databaseInterface;

	@Override
	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
			
		appContext = getApplicationContext();
		databaseInterface = new DatabaseInterface(appContext);
		
		try {
			databaseInterface.exportDatabase(DatabaseConstants.DATABASE_NAME);
			Toast.makeText(appContext, "The territory database was saved as " + DatabaseConstants.DATABASE_NAME , 5).show();
			finish();
		}
		catch (IOException e) {
			//TODO Handle the exception
		}
	}
}